import UICore from "../../../Core/Res/UICore";
import SdkTool from "../../../Core/Sdk/SdkTool";
import ProtoBufManager from "../../proto/ProtoBufManager";
import { common } from "../../proto/protoCmd";
import { GameModels } from "../socket/GameModels";

export class ModelPlayerInfo {
    public NickName: string = ``;//昵称
    public Avatar: string = ``;//头像地址
    public LobbyRoute: string;//大厅路由
    // public Account: string;
    public UserId: any;
    // public Gender: common.Gender;
    // public Vip: number;
    // public Gold: number;
    // public Diamond: number;
    private _recordData: { [k: string]: number } = {};

    private _eliminateCount: number = 0;
    private _winRate: number = 0;
    private _fightCount: number = 0;
    public setinfo(info: common.IUserBaseInfo): void {
        this.NickName = info.NickName || null;
        this.Avatar = info.Avatar || null;
        this.UserId = info.UserId || null;
        // this.Account = info.Account || null;
        // this.Gender = info.Gender || null;
        // this.Vip = info.Vip || null;
        // this.Gold = info.Gold || null;
        // this.Diamond = info.Diamond || null;
    }
    public get eliminateCount(): number {
        return this._eliminateCount;
    }
    public get winRate(): string {
        if (!this._fightCount) {
            return `0`;
        }
        return (this._winRate / this._fightCount * 100).toFixed(2);
    }
    public get fightCount(): number {
        return this._fightCount;
    }
    public set recordData(val) {
        this._recordData = val;
        this._fightCount = this._recordData[ProtoBufManager.ins.common.ERecordId.GameCount] | 0;
        this._winRate = this._recordData[ProtoBufManager.ins.common.ERecordId.GameWin] | 0;
        this._eliminateCount = this._recordData[ProtoBufManager.ins.common.ERecordId.GameKill] | 0;
    }
    public get userName(): string {
        if (!this.NickName) {
            if (!this.UserId) {
                return `147896`;
            }
            return this.UserId.toString();
        }
        return this.NickName;
    }
    public get headUrl(): string {
        if (!this.Avatar) {
            return UICore.getURL(`Common`, `icon`);
        }
        return this.Avatar;
    }
}